package com.ysy.logistics.entities.system;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ysy.logistics.entities.system.dto.DictDto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.List;

/**
 * @ClassDescription:
 * @Author:姚斯羽
 * @Create:2025/3/19 9:55
 **/
@Data
@TableName("sys_dict")
@Schema(name = "sys_dict", description = "字典类")
public class Dict {

    @TableId(value = "id", type = IdType.AUTO)
    @Schema(description = "字典id")
    private Integer id;
    @TableField(value = "num")
    @Schema(description = "字典值")
    private String num;
    @TableField(value = "pid")
    @Schema(description = "字典记录所属组id")
    private Integer pid;
    @TableField(value = "name")
    @Schema(description = "字典显示名称")
    private String name;
    @TableField(value = "tips")
    @Schema(description = "备注")
    private String tips;

    public DictDto toDto(List<Dict> children){
        DictDto dictDto = new DictDto();
        dictDto.setId(this.id);
        dictDto.setNum(this.num);
        dictDto.setPid(this.pid);
        dictDto.setName(this.name);
        dictDto.setTips(this.tips);
        dictDto.setChildren(children);
        return dictDto;
    }
}
